﻿using System;

namespace UnitBox {
	internal class InvokeInsteadInterceptionBehaviour : ReturnlessInterceptionBehaviour {

		#region instance fields

		private readonly Action _replacedInvocation;

		#endregion


		#region constructors

		public InvokeInsteadInterceptionBehaviour( Action invocationToReplaceWith ) {
			_replacedInvocation = invocationToReplaceWith;
		}

		#endregion


		#region public methods

		public override void Invoke() {
			_replacedInvocation.Invoke();
		}

		#endregion

	}


	internal class InvokeInsteadInterceptionBehaviour<TReturnValue> : ValueReturningInterceptionBehaviour<TReturnValue> {

		#region instance fields

		private readonly Func<TReturnValue> _replacedInvocation;

		#endregion


		#region constructors

		public InvokeInsteadInterceptionBehaviour( Func<TReturnValue> invocationToReplaceWith ) {
			_replacedInvocation = invocationToReplaceWith;
		}

		#endregion


		#region public methods

		public override TReturnValue Invoke() {
			return _replacedInvocation.Invoke();
		}

		#endregion

	}
}
